/**
 * 
 */
package com.aat.dxfy.thread.demo01;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @date 2016年6月29日 下午1:21:00
 * @author 新歌<xingeking@163.com>
 * @email  xingeking@163.com
 * @version v1.0
 * @function 功能是：
 * @info java spring 
 * @update none
 */
public class ThirdThread {
	public static void main(String[] args) {
		
		Callable<Integer> call=new Callable<Integer>() {
			public Integer call() throws Exception {
				int i=0;
				for(;i<10;i++){
					System.out.println(Thread.currentThread().getName() + " " + i);
				}
				return i;
			}
		};
		
		FutureTask<Integer> task=new FutureTask<Integer>(call);
		
		for (int i = 0; i < 10; i++) {
			System.out.println(Thread.currentThread().getName()+" "+i);
			if(i==5){
				new Thread(task,"返回值线程").start();
			}
		}
		
		try {
			System.out.println("子线程返回值："+task.get());
		} catch (InterruptedException e) {
			e.printStackTrace();
		} catch (ExecutionException e) {
			e.printStackTrace();
		}
	}
}
